﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using ABC.Business.Models;
using ABC.Core.Configuration;
using System.Linq;

namespace ABC.Controllers.ViewModels.My
{
    public class CalcKaskoExpressViewModel : BaseViewModel
    {
        protected readonly RbsCalcModel rbsCalcModel;

        public List<SelectListItem> BrandsAuto { get; set; }

        public List<SelectListItem> ModelsAuto { get; set; }

        public List<SelectListItem> Years { get; set; }

        public List<SelectListItem> Signalings { get; set; }

        public List<SelectListItem> Immos { get; set; }

        public List<SelectListItem> ListSex { get; set; }

        public List<SelectListItem> ListMarried { get; set; }

        public List<SelectListItem> ListChildren { get; set; }

        public List<SelectListItem> ListForCredit { get; set; }

        public string Driver { get; set; }

        public string Year { get; set; }

        public string BrandAuto { get; set; }

        public string ModelAuto { get; set; }

        public string Power { get; set; }

        public string Cost { get; set; }

        public string Path { get; set; }

        public string Signaling { get; set; }

        public string Immo { get; set; }

        public string Sex { get; set; }

        public string Married { get; set; }

        public string Children { get; set; }

        public string Credit { get; set; }

        public CalcKaskoExpressViewModel()
        {
            rbsCalcModel = IoC.Resolve<RbsCalcModel>();
            BrandsAuto = new List<SelectListItem>();
            ModelsAuto = new List<SelectListItem>();
            Years = new List<SelectListItem>();
            Signalings = new List<SelectListItem>();
            Immos = new List<SelectListItem>();
            ListMarried = new List<SelectListItem>();
            ListForCredit = new List<SelectListItem>();
            ListSex = new List<SelectListItem> { new SelectListItem { Text = "Мужчина", Value = "М" }, new SelectListItem { Text = "Женщина", Value = "Ж" } };
            ListChildren = new List<SelectListItem> { new SelectListItem { Text = "0", Value = "0" }, new SelectListItem { Text = "1", Value = "1" }, new SelectListItem{Text = "2", Value = "2"},
                                                        new SelectListItem{Text = "3", Value = "3"}, new SelectListItem{Text = "4", Value = "4"}, new SelectListItem{Text = "5", Value = "5"}, 
                                                        new SelectListItem{Text = "6", Value = "6"}, new SelectListItem{Text = "7", Value = "7"}, new SelectListItem{Text = "8", Value = "8"}, 
                                                        new SelectListItem{Text = "9", Value = "9"}, new SelectListItem{Text = "10", Value = "10"}};
            ListForCredit = rbsCalcModel.GetCredits().Select(x => new SelectListItem { Value = x.Key, Text = x.Value }).ToList();
            BrandsAuto = rbsCalcModel.GetDictionary("Марка");
            BrandsAuto.Insert(0, new SelectListItem { Value = "---", Text = "---" });
            ModelsAuto.Add(new SelectListItem { Value = "---", Text = "---" });
            Years = rbsCalcModel.GetDictionary("Год");
            Signalings = rbsCalcModel.GetDictionary("ЭПС");
            Signalings.ForEach(x => { switch (x.Text) { case "нет":x.Text = "Отсутствует"; return; } });
            Immos = rbsCalcModel.GetDictionary("Иммобилайзер");
            Immos.ForEach(x => { switch (x.Text) { case "Штатный":x.Selected = true; return; } });
            ListMarried = rbsCalcModel.GetDictionary("Наличие брака водителя");
        }

    }
}
